package com.fuyd.pms.dto;

import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Properties;

/**
 * Created by fuyongde on 2016/1/8.
 */
public class Result implements Serializable {

    private static Properties properties;

    static {
        try {
            properties = new Properties();
            InputStream inputStream = Result.class.getResourceAsStream("/error.properties");
            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 返回码
     **/
    private int code;
    /**
     * 消息
     **/
    private String msg;
    /**
     * 对象
     **/
    private Object data;

    public Result() {
        super();
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Result(int code, Object data) {
        this.code = code;
        this.data = data;
        this.msg = properties.getProperty(String.valueOf(code));
    }

    public Result(int code) {
        this.code = code;
        this.msg = properties.getProperty(String.valueOf(code));
        this.data = null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
